home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / fido / CrashMail125.lha / CrashMail / rexx / NotifyErrors.rexx < prev    next >
OS/2 REXX Batch file  |  1996-09-11  |  2KB  |  94 lines

  1. /*
  2.  
  3.    NotifyErrors.rexx 1.0 by Johan Billing 1995
  4.  
  5.    This script will scan CrashMail's logfile and send any lines with errors
  6.    (lines with the prefixes "!" or "%") to you in a message.
  7.  
  8. */
  9.  
  10. /* Configuring */
  11.  
  12. logfile = "Work:UMS/CrashMail/CrashMail.log"
  13. crashwrite = "Work:UMS/CrashMail/CrashWrite"
  14. notifyarea = "KCC_ERRORS"
  15. node = "2:200/207.6"
  16. inbound = "MAIL:Inbound"
  17.  
  18. /* Script starts here! */
  19.  
  20. options results
  21.  
  22. lastline=""
  23. lines=0
  24.  
  25. IF ~SHOW(Libraries,'rexxsupport.library') THEN
  26.     IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN EXIT
  27.  
  28. /* Start reading the log... */
  29.  
  30. call open('file',logfile,'R')
  31.  
  32. /* Skipping the part we have read already */
  33.  
  34. pos=0
  35.  
  36. do while ~eof('file')
  37.  str=readln('file')
  38.  if substr(str,21)="NotifyErrors.rexx logscan" then pos=seek('file',0,'Current')
  39. end
  40.  
  41. /* If we didn't find the string, the logfile must have been cleared and we
  42.    should read it from the beginning */
  43.  
  44. if substr(str,21)~="NotifyErrors.rexx logscan" then do
  45.  call seek('file',pos,'B')
  46. end
  47.  
  48. /* Scan for errors */
  49.  
  50. do while ~eof('file')
  51.  str = readln('file')
  52.  if str~="" then lastline=str
  53.  
  54.  if left(str,2)="! " | left(str,2)="% " then do
  55.   begin
  56.    if lines=0 then do
  57.     call open('outfile','T:NotifyErrors.tmp','W')
  58.    end
  59.  
  60.    call writeln('outfile',str)
  61.    lines=lines+1
  62.   end
  63. end
  64.  
  65. call close('file')
  66.  
  67. /* Write mark to logfile */
  68.  
  69. call open('file',logfile,'A')
  70. rawdate=date('n')
  71. date=left(rawdate,2) || "-" || substr(rawdate,4,3) || "-" || substr(rawdate,10,2)
  72.  
  73. /* "/" is the logfile prefix for miscellaneous information */
  74.  
  75. call writeln('file',"/ " || date || " " || time('n') || "  " || "NotifyErrors.rexx logscan")
  76. close('file')
  77.  
  78. /* No lines found? */
  79.  
  80. if lines=0 then exit
  81.  
  82. /* Close tempfile */
  83.  
  84. call writeln('outfile','')
  85. call close('outfile')
  86.  
  87. /* *** WRITING *** */
  88.  
  89. address command crashwrite 'FN "CrashMail" FA 'node' TN "All" TA 'node' SUBJ "Errors" ORIGIN "Yet another interesting message" AREA "'notifyarea'" DIR "'inbound'" T:NotifyErrors.tmp'
  90.  
  91. /* Yes, the line is VERY long... */
  92.  
  93. call delete('T:NotifyErrors.tmp')
  94.